package com.erli.exchange.common.sg;

import com.erli.exchange.common.sg.config.BaseClassInfo;

/**
 * Dao实现类生成器
 * 
 * @title DaoImplSourceGenerator.java
 * @package com.example.demo.sourcegenerate
 * @author lihu
 * @update 2019年3月8日 下午3:11:28
 */
public class DaoImplSourceGenerator extends AbstractSourceGenerator {

	@Override
	protected String getFileMainContent() {
		String entityClassName = this.getEntityClassName();
		String mapperClassName = this.getClassNameByBaseClassInfo(mapperClassInfo);
		String mapperInstanceName = this.getInstanceNameByClassName(mapperClassName);
		importSet.add(this.getFullClassImportByBaseClassInfo(entityClassInfo));
		importSet.add(this.getFullClassImportByBaseClassInfo(daoClassInfo));
		importSet.add(this.getFullClassImportByBaseClassInfo(mapperClassInfo));
		//		daoImplTemplate="    @Resource&#x000A;    private %s %s;&#x000A;&#x000A;    @Resource&#x000A;    private %s %s;&#x000A;&#x000A;&#x000A;    @Override    public BaseMapper&lt;%s&gt; getBaseMapper() {&#x000A;        return %s;&#x000A;    }&#x000A;&#x000A;"

		return String.format(templateInfo.getDaoImplTemplate(), mapperClassName, mapperInstanceName,
				 entityClassName, mapperInstanceName, entityClassName);
	}

	@Override
	protected String getFileFirstLineContent() {
		return String.format(templateInfo.getFileStart(), baseInfo.getClassType(), getClassName(),
				String.format(this.getSelfClassInfo().getExtendsTemplate(), this.getEntityClassName(),
						this.getClassNameByBaseClassInfo(daoClassInfo)));
	}

	@Override
	protected BaseClassInfo getSelfClassInfo() {
		return daoImplClassInfo;
	}
}
